public class Food extends Item{
    private boolean isHealthy;


    public Food(String name,double price,int number,boolean isHealthy){
        super(name,price,number);
        this.isHealthy=isHealthy;
        int random=(int)(10*Math.random());
    }

    @Override
    public boolean equals(Object obj) {
        try {
            Food food=(Food) obj;
            return super.equals(food)&&(food.isHealthy==this.isHealthy);
        }catch (ClassCastException e){
            return false;
        }
    }
    @Override
    public String toString() {
        if(isHealthy) {
            return "食品名：" + this.getName() + "，单价：" + this.getPrice() + "元" + "，数量" + this.getNumber() + "个（斤）。"+"健康食品";
        }
        else {
            return "食品名：" + this.getName() + "，单价：" + this.getPrice() + "元" + "，数量" + this.getNumber() + "个（斤）。"+"非健康食品";
        }
    }

    public boolean isHealthy() {
        return isHealthy;
    }
}
